package com.bawei.viewmodel_livedata_test;

import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;

public class NumViewModel2 extends ViewModel {
    private MutableLiveData<Integer> num;//liveData:可观察的数据类

    public MutableLiveData<Integer> getNum() {
        if(num == null){
            num = new MutableLiveData<>();
            num.setValue(0);//设置默认值：主线程执行
        }
        return num;
    }
}
